<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
	<div region="center" style="padding:1px;">
		<t:datagrid name="cbsEsPlanIpViewList" checkbox="false" fitColumns="false" 
			title="计划巡检" actionUrl="cbsEsPlanIpController.do?datagridOfViewList&source=${source }&departId=${departId }&year=${year }" idField="id" fit="true" queryMode="group">
			<t:dgCol title="影院ID"	field="id"  hidden="true"  width="120" />
			<t:dgCol title="影院名称"	field="cmName"		width="240" query="true" queryMode="single" />
			<t:dgCol title="巡检数量"	field="ipCount"		width="80" />
			<t:dgCol title="巡检年"		field="ipYear"		width="80" hidden="true" />
			<t:dgCol title="巡检月"		field="ipMonth"		width="80" query="true" queryMode="single" hidden="true" />
			<t:dgCol title="巡检年月"	field="ipDate"		width="80" />
			<t:dgCol title="最小保修截止日期"	    field="repairEndDate"		width="130" formatter="yyyy-MM-dd"/>
			<t:dgCol title="巡检服务商ID" 	field="ipCompany"	width="240" hidden="true" />
			<t:dgCol title="巡检服务商"	field="ipCompanyName"	width="240" query="true" queryMode="single" />
			<t:dgCol title="操作" field="opt" width="100" />
			<t:dgFunOpt title="查看" funname="goView"/>
			<t:dgFunOpt title="修改" funname="update"/>
			<t:dgToolBar title="查看" icon="icon-search"  funname="detail" />
		</t:datagrid>
	</div>
</div>
<script type="text/javascript">
$(function(){
	$("#ipCompanyName").removeAttr("onkeypress onkeydown").focus(function(){
		$.dialog({
			content: 'url:cbsEsPlanIpController.do?goQueryIpCpForEsPlanIp',
			zIndex: 2100,
			title: '选择服务商',
			lock: true,
			width: '800px',
			height: '500px',
			left: '85%',
			top: '65%',
			opacity: 0.4,
			init: function() {
				top.myWindow = window;
			},
			button: [{
				name: '确定',
				callback: function(){
					iframe = this.iframe.contentWindow;
					var text = iframe.getorgListSelections('shortname');
					if ($('#ipCompanyName').length >= 1) {
						$('#ipCompanyName').val(text);
						$('#ipCompanyName').blur();
					}
					if ($("input[name='ipCompanyName']").length >= 1) {
						$("input[name='ipCompanyName']").val(text);
						$("input[name='ipCompanyName']").blur();
					}
				},
				focus: true
			}, {
				name: '取消',
				callback: function() {}
			}]
		});
	});
	var ipMonthHtml = '<select name="ipMonth" id="ipMonth"><option value="">请选择</option>';
	for(var i = 1; i < 13;i++ ){
		ipMonthHtml += '<option value="'+ i +'">'+ i +'</option>';
	}
	ipMonthHtml += '</select>';
	
	$("#ipMonth").after(ipMonthHtml).remove();
	$("#cmName").removeAttr("onkeypress onkeydown").focus(function(){
		$.dialog({
			content: 'url:cbsEsPlanIpController.do?goQueryCmForEsPlanIp',
			zIndex: 2100,
			title: '选择影院',
			lock: true,
			width: '800px',
			height: '500px',
			left: '85%',
			top: '65%',
			opacity: 0.4,
			init: function() {
				top.myWindow = window;
			},
			button: [{
				name: '确定',
				callback: function(){
					iframe = this.iframe.contentWindow;
					var text = iframe.getcmListSelections('name');
					if ($('#cmName').length >= 1) {
						$('#cmName').val(text);
						$('#cmName').blur();
					}
					if ($("input[name='cmName']").length >= 1) {
						$("input[name='cmName']").val(text);
						$("input[name='cmName']").blur();
					}
				},
				focus: true
			}, {
				name: '取消',
				callback: function() {}
			}]
		});
	});
});
function detail(){
	var selected = $("#cbsEsPlanIpViewList").datagrid("getSelected");
	if(selected == null){
		tip("请选择一条要查看的项目");
		return;
	}
	openView(selected.id, selected.ipMonth);
}
function goView(index){
	var currItem = $("#cbsEsPlanIpViewList").datagrid("getRows")[parseInt(index)];
	openView(currItem.id, currItem.ipMonth);
}
function openView(cmId, ipMonth){
	createdetailwindow('计划巡检','cbsEsPlanIpController.do?goView&cmId=' + cmId + '&ipYear=${year}&ipMonth=' + ipMonth + '&source=${source }&departId=${departId }','800px','500px');
}
function update(index){
	var currItem = $("#cbsEsPlanIpViewList").datagrid("getRows")[parseInt(index)];
	createwindow('修改巡检单位及月份','cbsEsPlanIpController.do?goUpdate' + 
			'&cmId=' + currItem.id + '&ipYear=${year}&ipMonth=' + currItem.ipMonth + '&ipCompany=' + currItem.ipCompany + '&cmName=' + currItem.cmName + '&ipCount=' + currItem.ipCount + '&source=${source }','1120px','550px');
}
function updateCipCallBack(){
	var currentTab = top.$('#maintabs').tabs('getTab','自动生成巡检计划');
	var url = $($(currentTab.panel('options')).attr('content')).attr('src');
	top.$('#maintabs').tabs('update', {
		tab: currentTab,
		options: {
			content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>'
		}
	});
	
	//addOneTab('自动生成巡检计划',url);两种方式都可以刷新
}
</script>